<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core">

  <!-- INTERFACE -->
  <cc:interface>
      <cc:attribute name="objetos"/>
      <cc:attribute name="excluir"/>      
      <cc:attribute name="componente"/>
      <cc:attribute name="listarBean"/>
      <cc:attribute name="navegacao"/>
      <cc:attribute name="ativarIconeEditar"/>
      <cc:attribute name="ativarIconeRemover"/>
  </cc:interface>

  <!-- IMPLEMENTATION -->
  <cc:implementation>
      <fieldset>
          <legend>Resultado</legend>
          <h:dataTable value="#{cc.attrs.objetos}" var="objeto" styleClass="tabela"   headerClass="cabecalho" rowClasses="ultimo,primeiro"  width="100%">
              <cc:insertChildren/>

              <h:column rendered="#{cc.attrs.ativarIconeEditar}">
                  <f:facet name="header">
                        <h:outputText value="Editar"/>
                  </f:facet>
                  <h:link outcome="#{cc.attrs.navegacao}">
                      <f:param name="id" value="#{objeto.id}"/>
                      <h:graphicImage style="border: 0px;" value="#{resource['img:editar.png']}"/>
                  </h:link>
              </h:column>

              <h:column rendered="#{cc.attrs.ativarIconeRemover}">
                  <f:facet name="header">
                        <h:outputText value="Remover"/>
                  </f:facet>
                  <h:commandLink actionListener="#{cc.attrs.listarBean.remover(objeto)}">
                      <f:ajax render="@form"/>
                      <h:graphicImage style="border: 0px;" value="#{resource['img:remover.png']}"/>
                  </h:commandLink>
              </h:column>

              <f:facet name="footer">
                  <h:panelGrid columns="5" cellpadding="0" cellspacing="5" style="text-align:right">
                    <h:commandLink value="Primeiro" action="#{cc.attrs.listarBean.primeira}" disabled="#{cc.attrs.listarBean.primeiroRegistro == 0}">
                        <f:ajax execute="@this" render="@form"/>
                    </h:commandLink>
                    <h:commandLink value="Anterior"  action="#{cc.attrs.listarBean.anterior}" disabled="#{cc.attrs.listarBean.primeiroRegistro == 0}">
                        <f:ajax execute="@this" render="@form"/>
                    </h:commandLink>
                    <h:commandLink value="Próximo" action="#{cc.attrs.listarBean.proxima}" disabled="#{cc.attrs.listarBean.primeiroRegistro + cc.attrs.listarBean.registrosPorPagina >= cc.attrs.listarBean.totalRegistros}">
                        <f:ajax execute="@this" render="@form"/>
                    </h:commandLink>
                    <h:commandLink value="Último" action="#{cc.attrs.listarBean.pageLast}" disabled="#{cc.attrs.listarBean.primeiroRegistro + cc.attrs.listarBean.registrosPorPagina >= cc.attrs.listarBean.totalRegistros}">
                        <f:ajax execute="@this" render="@form"/>
                    </h:commandLink>
                    <h:outputText value="Page #{cc.attrs.listarBean.paginaCorrente} / #{cc.attrs.listarBean.totalPaginas}" />
                  </h:panelGrid>
              </f:facet>
          </h:dataTable>
      </fieldset>
  </cc:implementation>
</html>